package cn.dengta.webapp.trade.model;

import cn.dengta.common.util.Common;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum CashSubTypeMethod {

	PH_WALLET_GCASH("GCASH", 1, "Gcash", PaymentMethod.WALLET);

	final String code;
	@EnumValue
	final Integer label;
	final String info;
	final PaymentMethod method;

	CashSubTypeMethod(String code, Integer label, String info, PaymentMethod method) {
		this.code = code;
		this.label = label;
		this.info = info;
		this.method = method;
	}

	public static CashSubTypeMethod of(String code) {
		CashSubTypeMethod[] values = values();
		for (CashSubTypeMethod value : values) {
			if (value.code.equals(code)) {
				return value;
			}
		}
		return null;
	}

	public static CashSubTypeMethod ofLabel(Integer label) {
		return Common.getEnum(values(), CashSubTypeMethod::getLabel, label);
	}
}
